
function communal() {
    var grade = $("#grade").val();
    var phone = $("#phone").val();
    var age = $("#age").val();
    var stunumber = $("#stunumber").val();
    var realname = $("#realname").val();
    var username = $("#username").val();
    var password = $("#password").val();
    var password1 = $("#password1").val();
    if(!(username==""||password1==""||password==""||realname==""||stunumber==""||age==""||phone==""||grade=="")){
        $('#test').attr("disabled",false);
    }
}
function f1() {
    communal();
    if($("#realname").val()==""){
        $("#conreal").text("请输入您的姓名");
        $('#test').attr("disabled",true);
    }else $("#conreal").text("*");
}
function f2() {
    communal();
    if($("#stunumber").val()=="") {
        $("#connumber").text("请输入您的学号")
        $('#test').attr("disabled",true);}
    else $("#connumber").text("*")
}
function f3() {
    communal();
    if($("#age").val()=="") {
        $("#conage").text("请输入您的年龄");
        $('#test').attr("disabled",true);
    }
    else $("#age").text("*")
}
function f4() {
    communal();
    if($("#phone").val()=="") {
        $("#conphone").text("请输入您的手机号")
        $('#test').attr("disabled",true);
    }
    else $("#conphone").text("*")
}
function f5() {
    communal();
    if($("#grade").val()=="") {
        $("#congrede").text("请输入您的年级");
        $('#test').attr("disabled",true);
    }
    else $("#congrede").text("*")
}
function conpas() {
    communal();
    if($("#password").val()=="") {
        $("#conpas").text("密码不能为空");
        $('#test').attr("disabled",true);
    }else $("#conpas").text("*");
}
function decide() {
    communal();
    var username = $("#username").val();
    $.post("decide.do", {username:username}, function (data) {
        if($("#username").val()==""){
            $("#conuser").text("用户名不能为空");
        }
        else if(data.loginError=="F"){
            document.getElementById('username').style.border = '2px solid red';
            $("#conuser").text("用户名已存在");
        }else {
            $("#conuser").text("*");
            document.getElementById('username').style.border = '1px solid black';
        }
    })
}

function confirm(){
    communal();
    var password = $("#password").val();
    var password1 = $("#password1").val();
    if($("#password1").val()==""){
        document.getElementById('password1').style.border = '2px solid red';
        $("#confirm").text("确认密码不能为空")
    }
    else if(password!=password1){
        document.getElementById('password1').style.border = '2px solid red';
        document.getElementById('password').style.border = '2px solid red';
        document.getElementById("confirm").innerText="密码不一致";
    }
    else if(password1==password){
        document.getElementById('password1').style.border = '1px solid black';
        document.getElementById('password').style.border = '1px solid black';
        document.getElementById("confirm").innerText="*";
    }
}
function selectMajor() {
    var index=$('#cid option:selected').val();
    // 获取下拉框的value
    // var index1=$('#college option:selected').text();获取下拉框的值
    var majorJson=[];
    $.ajax({
        url:"selectMajor.do",
        type:"POST",
        data:{"cid":index},
        datatype:"json",
        success:function (data) {
            majorJson=data;
            var a =data.length;
            var selectObj = document.getElementById("mid");
            selectObj.options.length=0;
            selectObj.options.add(new Option("----请选择专业名称----"),"");
            for(var i=0;i<a;i++){
                selectObj.add(new Option(i+1+":"+majorJson[i].mname),i+1);
            }
        }
    })
}